# -*- coding:utf-8 -*-
from pathlib import Path

# p = Path('D:\Day08\Day97')

tree_str = ''
def generate_tree(pathname,n = 0):
    global tree_str
    if pathname.is_file():
        print('目录无效')
    elif pathname.is_dir():
        tree_str += '  |' * n + '-' * 4 + \
            str(pathname.relative_to(pathname.parent)) + '\\' + '\n'
        for cp in pathname.iterdir():
            generate_tree(cp, n + 1)

if __name__ == '__main__':
    generate_tree(Path.cwd())
    print(tree_str)
